package org.eae.eldf.dto.sys;

import java.util.ArrayList;
import java.util.List;

public class RolePurviewCheckDto {
	private String id;	
	private String text;
	private boolean leaf;
	private String state;
	private List<RolePurviewCheckDto> children = new ArrayList<RolePurviewCheckDto>();
	public List<RolePurviewCheckDto> getChildren() {
		return this.children;
	}
	public void setChildren(List<RolePurviewCheckDto> children) {
		this.children = children;
	}
	private String href;  
	private boolean checked;
	public boolean isChecked() {
		return this.checked;
	}
	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	public String getHref() {
		return this.href;
	}
	public void setHref(String href) {
		this.href = href;
	}
	
	//父节点ID
	private String parentid;
	private String iconCls;
    public String getIconCls() {
		return this.iconCls;
	}
	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}
	
	public String getParentid() {
		return this.parentid;
	}
	public void setParentid(String parentid) {
		this.parentid = parentid;
	}
	
	
	public String getId() {
		return this.id;
	}
	
	public String getText() {
		return this.text;
	}
	
	public boolean isLeaf() {
		return this.leaf;
	}
	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}
	public void setText(String text) {
		this.text = text;
	}
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * 检查儿子有没有被选中，儿子被选中了，就选中自己，如果一个儿子也没有被选中，撤销自己
	 */
	public void checkall(){
		if(this.isLeaf())
			return;
		int size=children.size();
		RolePurviewCheckDto node;
		boolean ch=false;
		for(int i=size-1;i>=0;i--){
			node=children.get(i);
			node.checkall();
			if(node.checked)
				ch=true;
		}
		checked=ch;
		
	}
	
	public void removeNoRight(){
    	int size=children.size();
    	RolePurviewCheckDto node;
    	for(int i=size-1;i>=0;i--){
    		node=children.get(i);
    		node.removeNoRight();
    		if((!node.isLeaf())&&node.getChildren().size()==0)
    		{	 
    			 children.remove(i);
    		}
    	}
    }
	
	
	
	
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	
}
